{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Padovan sequence\n", "\n", "The Padovan sequence is the following infinite sequence of natural numbers:\n", "`1 1 1 2 2 3 4 5 7 9 12 16 21 28 37 ...`\n", "\n", "The sequence begins with the subsquence $[1, 1, 1]$ and then each term is the sum of two terms before the last one, that is:\n", "\n", "$P(0) = 1$\n", "\n", "$P(1) = 1$\n", "\n", "$P(2) = 1$\n", "\n", "$P(n) = P(n-2) + P(n-3)$\n", "\n", "The Padovan sequence is a cousin of the Fibonacci sequence and has many applications in applied mathematics. As a curiosity, the Padovan sequence can be represented as a set of joined equilateral triangles forming an spiral:\n", "\n", "\"Padovan\n", "\n", "Recall that in Python, the last elements of the array can be accessed directly using negative indices, for example, `array[-1]` would be the last element of the array, `array [-2]` the second to last, and so on. Also, remember that the `append()` function, adds an element to the end of the array.\n", "\n", "With everything explained so far, **develop the following program**:\n", "\n", "A program that asks the user for a length and generates a Padovan sequence of that length, stores it in an array and prints the array. " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.4" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "nbformat": 4, "nbformat_minor": 4 }